package com.xuecheng.system.controller;


import com.xuecheng.api.system.DictionaryApi;
import com.xuecheng.api.system.model.dto.DictionaryDTO;
import com.xuecheng.system.service.DictionaryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class DictionaryController implements DictionaryApi {


    @Autowired
    private DictionaryService dictionaryService;


    /**
     * 根据code查询数据
     * @param code
     * @return
     */
    @GetMapping("/dictionary/{code}")
    public DictionaryDTO getDictionary(@PathVariable String code) {

        DictionaryDTO dictionaryDTO = dictionaryService.getDictionary(code);

        return dictionaryDTO;
    }


    /**
     * 查询全部
     * @return
     */
    @GetMapping("dictionary/all")
    public List<DictionaryDTO> queryAll() {

        List<DictionaryDTO> dictionaryDTOS = dictionaryService.queryAll();

        return dictionaryDTOS;
    }
}
